/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import dao.ItemDAO;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import model.Item;

/**
 *
 * @author Student
 */
public class ListItem implements Action{

    @Override
    public String execute(HttpServletRequest request) {
        ItemDAO dao = new ItemDAO();
        HttpSession sesi = request.getSession(true);
        List<Item> list = null;
        if(sesi.getAttribute("list")!=null){
            list = (ArrayList<Item>)sesi.getAttribute("list");
        }else{
            list = dao.getAll();
            sesi.setAttribute("list", list);
        }
        request.setAttribute("list", list);
        return "item_list.jsp";
    }
    
}
